package com.khalil.kkadmin.common.util;

import com.alibaba.fastjson2.JSON;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;

import java.util.List;

public class JsonUtil {

    public static ObjectMapper objectMapper = new ObjectMapper();

    public static String toJsonStr(Object obj) {
        return JSON.toJSONString(obj);
    }

    public static <T> List<T> parseJson2List(String json, Class<T> clazz) {
        return JSON.parseArray(json, clazz);
    }

    public static <T> T parseJson2Object(String json, Class<T> clazz) {
        return JSON.parseObject(json, clazz);
    }
}
